/**
 * Created by jiaaobo on 16/11/29.
 */

import Banner from "../../../common/component/Banner";
import Util from "util";
import API  from "api";



export default{
  name : "voucherList",
  data(){

    return{
      type : this.$route.params.type,
      imgList : [],
      voucherList :[]
    }

  },
  methods : {
    select : function(item){
      if(this.type == 'select'){
        Util.Storage.setSgObj("voucher",item);
        window.getRouter().go(-1);
      }
    }
  },
  computed : {

  },

  mounted : function(){

    //加载我的优惠券
    API.biz.queryUserCoupons(1)
      .then((res)=>{
        this.voucherList = res.bizData.couponInfos;
      });


    //加载banner
    API.biz.getBannerListByType("INDEX_PAGE")
      .then((res)=>{
        res.bizData.map((banner)=>{
          banner.url = banner.picUrl;
          banner.link = banner.pageUrl;
        });
        this.imgList = res.bizData;
      });
  },
  components:{
    Banner
  }
}
